import axios from 'axios'

let instance = axios()
export function get (url, params, headers) {
  let options = {}
  if (params) {
    options.params = params
  }
  if (headers) {
    options.headers = headers
  }
  return instance(url, options)
}
export default {
  post (url, params, headers) {
    let options = {}
    if (headers) {
      options.headers = headers
    }
    return instance.post(url, params, options)
  },
  put  (url, params, headers) {
    let options = {}
    if (headers) {
      options.headers = headers
    }
    return instance.put(url, params, options)
  },
  delete (url, params, headers) {
    let options = {}
    if (params) {
      options.params = params
    }
    if (headers) {
      options.headers = headers
    }
    return instance.delete(url, options)
  }
}
